#!/usr/bin/python
# -*- coding: utf-8 -*-

class AssociatedInstance:

    def __init__ (self, constraint_id):

        self._constraint_id = constraint_id
        
        self._src_role_satisfaction = 1.0
        self._src_speed_satisfaction = 1.0
        self._src_areas_satisfaction = 1.0
        self._src_displacement_x_satisfaction = 1.0
        self._src_displacement_y_satisfaction = 1.0

        self._dest_role_satisfaction = 1.0
        self._dest_areas_satisfaction = 1.0
        self._dest_displacement_x_satisfaction = 1.0
        self._dest_displacement_y_satisfaction = 1.0

        self._time_satisfaction = 1.0

        self._satisfaction_degree = 1.0

    def update_satisfaction_degree (self):

        self._satisfaction_degree = min(self._src_role_satisfaction, self._src_speed_satisfaction, self._src_areas_satisfaction, self._src_displacement_x_satisfaction, self._src_displacement_y_satisfaction, self._dest_role_satisfaction, self._dest_areas_satisfaction, self._dest_displacement_x_satisfaction, self._dest_displacement_y_satisfaction, self._time_satisfaction)

        return self._satisfaction_degree

    def __str__ (self):

        aux = 'Constraint instance: ' + self._constraint_id + '\n'

        aux += ('\t[SRC_Role: ' + str(self._src_role_satisfaction) + '] ')
        aux += ('[SRC_Speed: ' + str(self._src_speed_satisfaction) + '] ')
        aux += ('[SRC_Areas: ' + str(self._src_areas_satisfaction) + '] ')
        aux += ('[SRC_Displacement: ' + str(self._src_displacement_x_satisfaction) + ', ' + str(self._src_displacement_y_satisfaction) + ']\n')

        aux += ('\t[DEST_Role: ' + str(self._dest_role_satisfaction) + '] ')
        aux += ('[DEST_Areas: ' + str(self._dest_areas_satisfaction) + '] ')
        aux += ('[DEST_Displacement: ' + str(self._dest_displacement_x_satisfaction) + ', ' + str(self._dest_displacement_y_satisfaction) + ']\n')

        aux += ('\t[Time: ' + str(self._time_satisfaction) + ']\n')

        aux += ('\t[Global satisfaction degree: ' + str(self._satisfaction_degree) + ']\n')

        return aux
